﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JiebaNet.Segmenter;
using JiebaNet.Segmenter.PosSeg;


namespace JiebaSegment
{
    class Program
    {
        static void Main(string[] args)
        {
            var dic = AppDomain.CurrentDomain.BaseDirectory;
            var segment = new JiebaSegmenter();

            string str = "中华人民共和国于1949年10月1日成立，所以这一天也成为了中国的国庆节。云计算是新技术！";
            var cut1 = segment.Cut(str);//默认精确模式
            var cut2 = segment.Cut(str, cutAll: true);//全模式
            var cut3 = segment.CutForSearch(str);//搜索引擎模式
            var cut4 = new PosSegmenter().Cut(str);
            foreach (var item in cut1)
            {
                Console.Write($" {item} ");
            }
            Console.WriteLine();

            foreach (var item in cut1)
            {
                Console.Write($" {item} ");
            }
            Console.WriteLine();

            foreach (var item in cut4)
            {
                Console.Write($" {item.Word}:{item.Flag} ");
            }
            Console.WriteLine();

            foreach (var item in cut3)
            {
                Console.Write($" {item} ");
            }
            Console.WriteLine();
            var importent = new JiebaNet.Analyser.TfidfExtractor().ExtractTagsWithWeight(str);//关键词提取  ifd
            foreach (var item in importent)
            {
                Console.Write($" {item.Word}:{item.Weight} ");
            }
            Console.WriteLine();

            var importent2 = new JiebaNet.Analyser.TextRankExtractor().ExtractTags(str);//关键词提取  textrank
            foreach (var item in importent2)
            {
                Console.Write($" {item} ");
            }
            Console.WriteLine();

            //segment.LoadUserDict("Test.txt");
            segment.AddWord("云计算", 5);

            Console.WriteLine("加载完用户词典后");
            cut1 = segment.Cut(str);//默认精确模式
            foreach (var item in cut1)
            {
                Console.Write($" {item} ");
            }
            Console.WriteLine();
            Console.ReadLine();
        }
    }
}
